#include "stm32f10x.h"
#include "bsp_led.h"
#include "bsp_buzzer.h"
#include "systick.h"
#include "bsp_key.h"
#include "bsp_seg_595.h"

extern uint8_t SEG_Code[16];
uint8_t key1_pressed_flag=0;
uint8_t key2_pressed_flag=0;

void KEY_SCAN_FLAG(void)
{
	static uint8_t key1_old=1,key2_old=1;
		uint8_t key1_now,key2_now;
	
	key1_now=GetKEY1();
	if(key1_old==1 && key1_now==0){
		key1_pressed_flag=1;
	}
	key1_old=key1_now;
	
	key2_now=GetKEY2();
	if(key2_old==1 && key2_now==0){
		key2_pressed_flag=1;
	}
	key2_old=key2_now;
	
	
}


int main(void)
{
	
	SysTick_Init(); 
	KEY_GPIO_Config();
  SEG_595_GPIO_Config();
	
	uint8_t dis_num=0;
	while (1)
	{
    KEY_SCAN_FLAG();
		if(key1_pressed_flag){
		key1_pressed_flag=0;
			if(++dis_num>15) dis_num=0;
		}
		
		if(key2_pressed_flag){
		key2_pressed_flag=0;
			if(--dis_num>254) dis_num=15;
		}
    SendOneChar_595(SEG_Code[dis_num]);
		
		SysTick_Delay_Nms(1);
		
  }



}
